<template>
  <div>
    <el-button type="primary" @click="dialogTableVisible = true">修改</el-button>
    <el-dialog v-el-drag-dialog title="修改" :visible.sync="dialogTableVisible" @close='close'>
      <el-form  ref="row_data" label-position="left" label-width="70px" style='width: 400px; margin-left:50px;'>
                <el-form-item :label="'id'" prop="id">
          <el-input placeholder="id" v-model="row_data.id"></el-input>
        </el-form-item>
                <el-form-item :label="'用户名'" prop="user_name">
          <el-input placeholder="用户名" v-model="row_data.user_name"></el-input>
        </el-form-item>
                <el-form-item :label="'性别'" prop="sex">
          <el-input placeholder="性别" v-model="row_data.sex"></el-input>
        </el-form-item>
                <el-form-item :label="'手机'" prop="phone">
          <el-input placeholder="手机" v-model="row_data.phone"></el-input>
        </el-form-item>
                <el-form-item :label="'年龄段'" prop="age_range">
          <el-input placeholder="年龄段" v-model="row_data.age_range"></el-input>
        </el-form-item>
                <el-form-item :label="'头像'" prop="headimg">
          <el-input placeholder="头像" v-model="row_data.headimg"></el-input>
        </el-form-item>
                <el-form-item :label="'等级'" prop="rank_id">
          <el-input placeholder="等级" v-model="row_data.rank_id"></el-input>
        </el-form-item>
                <el-form-item :label="'余额'" prop="balance">
          <el-input placeholder="余额" v-model="row_data.balance"></el-input>
        </el-form-item>
                <el-form-item :label="'系统标识'" prop="sys_sign">
          <el-input placeholder="系统标识" v-model="row_data.sys_sign"></el-input>
        </el-form-item>
                <el-form-item :label="'帐号id'" prop="account_id">
          <el-input placeholder="帐号id" v-model="row_data.account_id"></el-input>
        </el-form-item>
                <el-form-item>
          <el-button type="primary" @click="submitForm()">立即创建</el-button>
          <el-button @click="close()">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
  import elDragDialog from '@/directive/el-dragDialog' // base on element-ui
  import store from '@/store'
  import { edit } from '@/api/user/user'

  export default {
    name: 'dragDialog-demo',
    directives: { elDragDialog },
    props: ['row_data'],
    data() {
      return {
        dialogTableVisible: false
      }
    },
    created: function() {
      console.log(this.row_data)
    },
    methods: {
      submitForm() {
        edit(store.getters.token, this.row_data).then(res => {
          this.close()
        })
      },
      close() {
        this.$emit('getLists')
        this.dialogTableVisible = false
      }
    }
  }
</script>
